import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex)
import axios from 'axios'
import {
  GetaddListData
} from '@/request/api'
export default new Vuex.Store({
  state: {
    cartTotal: {
      checkedGoodsAmount: 0,
      checkedGoodsCount: 0,
      goodsAmount: 0,
      goodsCount: 0,
    },
    cartList: [],

  },
  mutations: {
    setCartList: function(state, cartList) {
      state.cartList = cartList
    },
    setCartTotal:function(state,cartTotal){
      state.cartTotal = cartTotal
    }
  },
  getters: {

  },
  actions: {
    AjaxCart:function(content){
      GetaddListData().then(res => {
        console.log(res.data.cartList)
        content.commit('setCartList',res.data.cartList)
        content.commit('setCartTotal',res.data.cartTotal)
      });

    }

  }
})
